package com.chen.framework.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.dev33.satoken.stp.StpUtil;
import cn.dev33.satoken.util.SaResult;
import com.chen.root.oclass.dto.UserInfoDTO;
import com.chen.root.oclass.vo.LoginVO;
import com.chen.framework.service.inter.AuthUserService;
import com.chen.root.base.R;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/authUser")
@Api(value = "sys_user",tags = "用户信息管理API")
@AllArgsConstructor
public class AuthUserController {

    @Resource
    AuthUserService authUserService;

    @PostMapping("/info")
    @Operation(summary = "[内部接口]获取用户账号信息",description = "[内部接口]获取用户账号信息")
    public R<UserInfoDTO> userInfo(@RequestBody LoginVO params){
        return authUserService.userInfo(params);
    }

    @PostMapping("/infoByPhone")
    @Operation(summary = "[内部接口]获取用户账号信息",description = "[内部接口]获取用户账号信息")
    public R<UserInfoDTO> userInfoByPhone(@RequestBody LoginVO params){
        return authUserService.userInfoByPhone(params);
    }

    @SaIgnore
    @PostMapping("/isLogin")
    public Object isLogin() {
        return SaResult.data(StpUtil.isLogin());
    }
}
